import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Http, Response, RequestOptions, Headers, URLSearchParams } from '@angular/http';

import { HttpRouter } from '../service/httpRouter'
import { HttpService } from '../service/httpService'

@Component({
  selector: 'app-feedback',
  templateUrl: './feedback.component.html',
  styleUrls: ['./feedback.component.less']
})
export class FeedbackComponent implements OnInit {

  private title = "问题反馈";
  public feedbackForm: FormGroup;
  public dialogStatus = false;
  contact:any = {};
  status:boolean = false;


  constructor(
    private httpRouter : HttpRouter,
    private httpService : HttpService
  ) { }

  ngOnInit() {
  }

  pubFeedback(){
    if(this.contact.comment != null && this.contact.comment != ""){
      let data = new URLSearchParams();
      data.append('comment', this.contact.comment);

      this.httpService.post(this.httpRouter.putFeedbackUrl,data).subscribe(data => {
        if(data.code === "10200"){
          this.status = true;
        }else{
          this.dialogStatus = true;
        }
      });
    }

  }

  closed(){
    this.dialogStatus = false;
  }
}
